﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormSection" Src="~/_controltemplates/InputFormSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" Src="~/_controltemplates/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" Src="~/_controltemplates/ButtonSection.ascx" %>
<%@ Register TagPrefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Assembly Name="Winwise.SPWebConfig.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=497a758e307ba99d" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddEditXPathXmlWebconfigModification.aspx.cs"
    Inherits="Winwise.SPWebConfig.UI.AddEditXPathXmlWebconfigModification" MasterPageFile="~/_admin/admin.master" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <table width="100%" class="propertysheet" cellspacing="0" cellpadding="0" border="0">
        <tr>
            <td class="ms-descriptionText">
                <asp:Label ID="LabelMessage" runat="server" EnableViewState="False" class="ms-descriptionText" />
            </td>
        </tr>
        <tr>
            <td class="ms-error">
                <asp:Label ID="LabelErrorMessage" runat="server" EnableViewState="False" />
            </td>
        </tr>
        <tr>
            <td class="ms-descriptionText">
                <asp:ValidationSummary ID="ValSummary" HeaderText="<%$SPHtmlEncodedResources:spadmin, ValidationSummaryHeaderText%>"
                    DisplayMode="BulletList" ShowSummary="True" runat="server"></asp:ValidationSummary>
            </td>
        </tr>
    </table>
    <table border="0" cellspacing="0" cellpadding="0" width="100%">
        <wssuc:inputformsection runat="server" id="idWebApplicationSelectorSection" title="<%$Resources:spadmin, multipages_webapplication_title%>"
            description="<%$Resources:spadmin, multipages_webapplication_desc%>">
            <template_inputformcontrols>
			        <tr><td>
			        <SharePoint:WebApplicationSelector id="Selector" runat="server"
				        OnContextChange="OnContextChange" />
			        </td></tr>
		        </template_inputformcontrols>
        </wssuc:inputformsection>
        <wssuc:inputformsection title="Parent XPath" runat="server">
		        <Template_Description>
                    <div style="width:300px">
			          Fill the textbox with the XPath to the <b>parent</b> element you wish to Add/Modify.
                    </div>
		        </Template_Description>
		        <Template_InputFormControls>
			         <wssuc:InputFormControl LabelText="Parent XPath" runat="server">
				        <Template_control>
                         <div style="min-width:400px">
                            <asp:TextBox runat="Server" ID="TBParentXPath" Width="100%" />
                            <br/><br/>Ex : configuration/system.webServer/modules
                            </div>
				        </Template_control>
			        </wssuc:InputFormControl>
		        </Template_InputFormControls>
	        </wssuc:inputformsection>
        <wssuc:inputformsection title="Relative XPath" runat="server">
		        <Template_Description>
			       Fill the textbox with the relative (from the parent) XPath to the element you wish to Add/Modify.
		        </Template_Description>
		        <Template_InputFormControls>
			        <wssuc:InputFormControl LabelText="Relative XPath" runat="server" >
				        <Template_control>
					         <asp:TextBox runat="Server" ID="TBRelativeXPath" Width="100%" />
                             <br/><br/>Ex : add[@name="MyHttpModule"]
				        </Template_control>
			        </wssuc:InputFormControl>
                </Template_InputFormControls>
	        </wssuc:inputformsection>
        <wssuc:inputformsection title="Modification type" runat="server">
		    <Template_Description>
			   Select the modification type you wish to perform
		    </Template_Description>
		    <Template_InputFormControls>
			    <wssuc:InputFormControl LabelText="Modification type" runat="server" >
				    <Template_control>
					        <asp:RadioButtonList runat="server" ID="RBLType" OnSelectedIndexChanged="RBLType_SelectedIndexChanged"
                                AutoPostBack="true" RepeatDirection="Horizontal">
                                <asp:ListItem Text="Add Node" Selected="True" />
                                <asp:ListItem Text="Modify Attribute" />
                            </asp:RadioButtonList>
				    </Template_control>
			    </wssuc:InputFormControl>
            </Template_InputFormControls>
	    </wssuc:inputformsection>
        <wssuc:inputformsection title="Value" runat="server">
		    <Template_Description>
			    Fill the textbox with the value you wish to add/modify.<br />
                For modification type "add node", put XML nodes.<br />
                For modification type "Modify Attribute", put the Atrribute value
		    </Template_Description>
		    <Template_InputFormControls>
			    <wssuc:InputFormControl LabelText="Value" runat="server" >
				    <Template_control>
                        <asp:TextBox  runat="Server" ID="TBValue" TextMode="MultiLine" Rows="5" Width="100%" />
                        <br /><br />
                        Ex (node): &lt;add name="MyHttpModule" type="MyNamespace.MyHttpModule, MyAssembly" /&gt;  <br />
                        Ex (attribute): true
				    </Template_control>
			    </wssuc:InputFormControl>
            </Template_InputFormControls>
	    </wssuc:inputformsection>
        <wssuc:inputformsection id="SectionNodePosition" title="Insert Node position" runat="server">
		    <Template_Description>
			  Select where the new node should be placed.<br />
              If you select First or Last Child, it will be relatively to its parent. <br />
              If tou select Before or after sibling, it will be relatively to its sibling (see Relative Sibling XPath)
		    </Template_Description>
		    <Template_InputFormControls>
			    <wssuc:InputFormControl LabelText="Insert Node position" runat="server" >
				    <Template_control>
                         <asp:RadioButtonList runat="server" ID="RBNodeType" RepeatDirection="Vertical"
                            OnSelectedIndexChanged="RBNodeType_SelectedIndexChanged" AutoPostBack="true">
                            <asp:ListItem Text="Last Child" Selected="True" />
                            <asp:ListItem Text="First Child" />
                            <asp:ListItem Text="Before Sibling" />
                            <asp:ListItem Text="After Sibling" />
                        </asp:RadioButtonList>
				    </Template_control>
			    </wssuc:InputFormControl>
            </Template_InputFormControls>
	    </wssuc:inputformsection>
        <wssuc:inputformsection id="SectionNodeRelativeSiblingXPath" title="Relative sibling XPath"
            runat="server">
		    <Template_Description>
			    Fill the textbox with the relative (from the parent) XPath to the sibling element. It will be used to know where to insert the new nodes.
		    </Template_Description>
		    <Template_InputFormControls>
			    <wssuc:InputFormControl LabelText="Relative sibling XPath" runat="server" >
				    <Template_control>
                         <asp:TextBox runat="Server" ID="TBRelativeSiblingXPath" Width="100%" />
                         <br /><br />Ex : add[@name=""SPRequestModule""] (to insert a new httpmodule just before/after this httpmodule)
				    </Template_control>
			    </wssuc:InputFormControl>
            </Template_InputFormControls>
	    </wssuc:inputformsection>
        <wssuc:inputformsection id="SectionNodeOptions" title="Options" runat="server">
		    <Template_Description>
			    UnCheck the "Erase Node On Remove" Checkbox if you wish to keep the XML nodes even after unapplying modification
		    </Template_Description>
		    <Template_InputFormControls>
			    <wssuc:InputFormControl LabelText="Erase Node On Remove" runat="server" >
				    <Template_control>
                            <asp:CheckBox runat="server" ID="CBEraseNodeOnRemove" Text="Erase Node On Remove" Checked="true" />
				    </Template_control>
			    </wssuc:InputFormControl>
            </Template_InputFormControls>
	    </wssuc:inputformsection>
        <wssuc:inputformsection title="Common settings" runat="server">
		    <Template_Description>
			    The Name will be use for display info only<br />
                Select the zones you wish the modification should be applyed 
		    </Template_Description>
		    <Template_InputFormControls>
			    <wssuc:InputFormControl LabelText="Display Name" runat="server" >
				    <Template_control>
                           <asp:TextBox runat="Server" ID="TBDisplayName" Width="100%" />
				    </Template_control>
			    </wssuc:InputFormControl>
                 <wssuc:InputFormControl LabelText="Zones" runat="server" >
				    <Template_control>
                           <asp:CheckBoxList runat="server" ID="CheckBoxZones" RepeatDirection="Horizontal">
                                <asp:ListItem Text="Default" Selected="True"/>
                                <asp:ListItem Text="Intranet" Selected="True"/>
                                <asp:ListItem Text="Internet" Selected="True"/>
                                <asp:ListItem Text="Extranet" Selected="True"/>
                                <asp:ListItem Text="Custom" Selected="True"/>
                            </asp:CheckBoxList>
				    </Template_control>
			    </wssuc:InputFormControl>
            </Template_InputFormControls>
	    </wssuc:inputformsection>
        <wssuc:buttonsection runat="server">
		    <Template_Buttons>
			   <asp:Button runat="server" ID="BtnAddModif" OnClick="AddModif" Text="Add / Save XPath/Xml transformation" />
               <asp:Button ID="Button1" runat="Server" Text="Apply web.config modifications" OnClick="ApplyWebConfigModif" />
		    </Template_Buttons>
	    </wssuc:buttonsection>
    </table>
  
    <asp:Label runat="Server" ID="LblResults" />
    <br />
    <a href="/_admin/Winwise.SPWebConfig/ManageWebConfigModif.aspx" rel="sp_DialogLinkInternal"
        runat="server" id="LinkManage">Manage web.config modifications</a>
</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    XPath/Xml Web Config Modification page
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
    runat="server">
    XPath/Xml Web Config Modification page
</asp:Content>
